﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using IGGWindowApp.Data;

namespace IGGWindowApp.Panels
{
    public partial class PanelStatistics : UserControl
    {
        // EVENTS
        public delegate void ItemSelectedHandler(string item);
        public event ItemSelectedHandler ItemSelected;

        public PanelStatistics()
        {
            InitializeComponent();
            lsStats.Items.Add(new StatsCombo("Batting Average", "Hits", "Batting Average"));
            lsStats.Items.Add(new StatsCombo("On-Base%", "Bases on Balls", "On Base Percentage"));
            lsStats.Items.Add(new StatsCombo("Doubles", "Triples", "Doubles & Triples"));
            lsStats.Items.Add(new StatsCombo("Homeruns", "Slugging", "Power"));
            lsStats.Items.Add(new StatsCombo("RBI", "Runs", "Scoring"));
            lsStats.Items.Add(new StatsCombo("SB", "SB%", "Base Running"));
            lsStats.Items.Add(new StatsCombo("WAR", "XBH", "WAR"));
            lsStats.Items.Add(new StatsCombo("OPS+", "AB/HR", "OPS+ & AB/HR"));
            lsStats.Items.Add(new StatsCombo("GDP", "HBP", "GDP & HBP")); 
            lsStats.Items.Add(new StatsCombo("Strikeouts", "IBB", "Strikeouts"));
            lsStats.Items.Add(new StatsCombo("Wins", "Losses", "Wins & Losses"));
            lsStats.Items.Add(new StatsCombo("ERA", "Strikeouts", "ERA & Strikeouts"));

            lsStats.SelectedIndex = 0;
        }

        private void panelTitle_ItemSelected(string item)
        {
            ItemSelected(item);
        }

        private class PanelStatsItem : Panel
        {
            private Label m_name;
            private Label m_value;

            public PanelStatsItem()
            {
                this.Size = new System.Drawing.Size(165, 17);
                m_name = CreateLabel("John Smith, CHC", 3);
                m_value = CreateLabel(".345", 209);

                this.Controls.Add(m_name);
                this.Controls.Add(m_value);
            }

            private Label CreateLabel(string text, int xpos)
            {
                Label lbl = new Label();
                lbl.AutoSize = true;
                lbl.Font = new System.Drawing.Font("Franklin Gothic Book", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                lbl.Location = new System.Drawing.Point(xpos, 0);
                lbl.Size = new System.Drawing.Size(37, 17);
                lbl.Text = text;
                return lbl;
            }
        }

        public class StatsCombo
        {
            public string Stat1 { get; set; }
            public string Stat2 { get; set; }
            public string Label { get; set; }

            public StatsCombo(string st1, string st2, string lbl)
            {
                Stat1 = st1;
                Stat2 = st2;
                Label = lbl;
            }

            public override string ToString()
            {
                return Label;
            }
        }

    }
}
